// 模拟实现lodash中得 flowRight 
const _= require('lodash')
const reverse = arr=> arr.reverse()
const first = arr => arr[0]
const toup = arr=> arr.toUpperCase()

const f = _.flowRight(toup, first, reverse)
console.log(f(['one', 'tow', 'three']))

function compose (...args) {
    return function(value) {
        return args.reverse().reduce(function(acc, fn) {
            return fn(acc)
        }, value)
    }
}
// es6
const compose = (...args) => value=> args.reverse().reduce((acc, fn)=> fn(acc), value)

const f1 = compose(toup, first, reverse)
console.log(f1(['one', 'tow', 'three']))